import 'package:boss/provider/login_user_provider.dart';
import 'package:boss/ui/page/login/constant/login_type.dart';
import 'package:boss/ui/page/login/provider/login_provider.dart';
import 'package:boss/ui/page/login/widget/login_form.dart';
import 'package:boss/ui/page/login/widget/login_function_bar.dart';
import 'package:boss/ui/page/login/widget/login_toggle_btn.dart';
import 'package:boss/ui/widget/loginRegistForget/lrf_btn.dart';
import 'package:boss/ui/widget/loginRegistForget/lrf_title.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class LoginBrowser extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      padding: EdgeInsets.all(0),
      child: Column(
        children: <Widget>[
          Container(
            height: 88.w +
                MediaQuery.of(context).padding.top,
          ),
          LRFTitle(
            '登录你的门店',
          ),
          LoginForm(),
          LoginToggleBtn(),
          LRFBtn(
            title: '登 录',
            onTap: () {
              var loginProvider = Provider.of<LoginProvider>(
                context,
                listen: false,
              );
              var loginUserProvider = Provider.of<LoginUserProvider>(
                context,
                listen: false,
              );

              loginProvider.loginType == LoginType.userPassword
                  ? loginUserProvider.newUserLogin(
                      context,
                      phone: loginProvider.phone,
                      password: loginProvider.password,
                    )
                  : loginUserProvider.loginByVerifyCode(
                      context,
                      phone: loginProvider.phone,
                      code: loginProvider.code,
                    );
            },
          ),
          LoginFunctionBar(),
        ],
      ),
    );
  }
}
